import NetEngine


client = NetEngine.NetEngine()


def server_notify(event, host, port):
    print("server_notify", event, host, port)


def data_notify(is_recv, data):
    print("data_notify", is_recv, data)
    if is_recv:
        client.send(data)


client.register_data_notify(data_notify)
client.register_client_event_notify(server_notify)
client.start_connect('localhost', 50200)
print('输入\'q\'断开连接，输入\'e\'开始连接，已开始连接')
while True:
    ch = input()
    if ch == 'q':
        client.disconnect()
    elif ch == 'e':
        client.start_connect("localhost", 50200)
